var requireWithoutCache = require('require-without-cache');
var util = requireWithoutCache('../miscellaneous/util.js', require);

var resourceProperty = requireWithoutCache('../controllers/common.js', require);

var httpProxy = require('http-proxy');
var proxyServer = httpProxy.createProxyServer({});

module.exports = {
  '/public/upload': function(req, res) {
    //我自己写那个不能代理静态的图片
    //util.proxy(req, res, resourceProperty.getUrl());

    try {
      proxyServer.web(req, res, {
        target: resourceProperty.getUrl() || 'http://127.0.0.1',
        secure: true
      });
    } catch (e) {
      log.error(e);
    }
  }
};
